package com.miao.im.support;

import com.miao.im.server.session.SessionContext;

import java.util.Optional;

/**
 * @Auther: miaoguoxin
 * @Date: 2021/4/13 16:51
 * @Description:
 */
public class SocketSessionHolder {


    public static final ThreadLocal<SessionContext> LOCAL = new ThreadLocal<>();

    public static void set(SessionContext userDo) {
        LOCAL.set(userDo);
    }

    public static Optional<SessionContext> get() {
        return Optional.ofNullable(LOCAL.get());
    }

    public static void remove() {
        LOCAL.remove();
    }


}
